﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TruckWatch.Cloud.Models.EF;
using TruckWatch.Cloud.DAL;

namespace TruckWatch.Cloud.BusinessLogic
{
    public static class TripBL
    {
        public static int GetTripIdForCurrentDateTime(int driverId)
        {
            //TODO:
            return 0;
        }

        public static void AddTrip(Trip trip)
        {
            // validate

            //
            TruckWatchEntities context = new TruckWatchEntities();
            context.AddToTrips(trip);
            context.SaveChanges();

        }


        public static void DeleteTrip(int tripId)
        {
            TruckWatchEntities context = new TruckWatchEntities();
            Trip trip = context.Trips.First(x => x.Id == tripId);
            context.Trips.DeleteObject(trip);
            context.SaveChanges();
        }
    }
}
